
package com.sunwayhorizo.health.hl7.datatypes.common.gtsparser;

import com.sunwayhorizo.health.hl7.common.VersionInfo;

// Referenced classes of package oracle.apps.ctb.hl7.types.common.gtsparser:
//            OIDParserConstants, SimpleCharStream, Token, TokenMgrError


public class OIDParserTokenManager implements OIDParserConstants
{
    public static final String RCS_ID
	= "$Header: OIDParserTokenManager.java 115.1 2005/09/16 11:11:37 mmoores noship $";
    public static final boolean RCS_ID_RECORDED
	= (VersionInfo.recordClassVersion
	   ("$Header: OIDParserTokenManager.java 115.1 2005/09/16 11:11:37 mmoores noship $",
	    "oracle.apps.ctb.hl7.types.common.gtsparser"));
    static final int[] jjnextStates = new int[0];
    public static final String[] jjstrLiteralImages = { "", null, "." };
    public static final String[] lexStateNames = { "DEFAULT" };
    protected SimpleCharStream input_stream;
    private final int[] jjrounds = new int[1];
    private final int[] jjstateSet = new int[2];
    protected char curChar;
    int curLexState;
    int defaultLexState;
    int jjnewStateCnt;
    int jjround;
    int jjmatchedPos;
    int jjmatchedKind;
    
    private final int jjStopStringLiteralDfa_0(int i, long l) {
	switch (i) {
	default:
	    return -1;
	}
    }
    
    private final int jjStartNfa_0(int i, long l) {
	return jjMoveNfa_0(jjStopStringLiteralDfa_0(i, l), i + 1);
    }
    
    private final int jjStopAtPos(int i, int i_0_) {
	jjmatchedKind = i_0_;
	jjmatchedPos = i;
	return i + 1;
    }
    
    private final int jjStartNfaWithStates_0(int i, int i_1_, int i_2_) {
	jjmatchedKind = i_1_;
	jjmatchedPos = i;
	try {
	    curChar = input_stream.readChar();
	} catch (java.io.IOException ioexception) {
	    return i + 1;
	}
	return jjMoveNfa_0(i_2_, i + 1);
    }
    
    private final int jjMoveStringLiteralDfa0_0() {
	switch (curChar) {
	case '.':
	    return jjStopAtPos(0, 2);
	default:
	    return jjMoveNfa_0(0, 0);
	}
    }
    
    private final void jjCheckNAdd(int i) {
	if (jjrounds[i] != jjround) {
	    jjstateSet[jjnewStateCnt++] = i;
	    jjrounds[i] = jjround;
	}
    }
    
    private final void jjAddStates(int i, int i_3_) {
	do
	    jjstateSet[jjnewStateCnt++] = jjnextStates[i];
	while (i++ != i_3_);
    }
    
    private final void jjCheckNAddTwoStates(int i, int i_4_) {
	jjCheckNAdd(i);
	jjCheckNAdd(i_4_);
    }
    
    private final void jjCheckNAddStates(int i, int i_5_) {
	do
	    jjCheckNAdd(jjnextStates[i]);
	while (i++ != i_5_);
    }
    
    private final void jjCheckNAddStates(int i) {
	jjCheckNAdd(jjnextStates[i]);
	jjCheckNAdd(jjnextStates[i + 1]);
    }
    
    private final int jjMoveNfa_0(int i, int i_6_) {
	int i_7_ = 0;
	jjnewStateCnt = 1;
	int i_8_ = 1;
	jjstateSet[0] = i;
	int i_9_ = 2147483647;
	for (;;) {
	    if (++jjround == 2147483647)
		ReInitRounds();
	    if (curChar < '@') {
		long l = 1L << curChar;
	    while_4_:
		for (;;) {
		    switch (jjstateSet[--i_8_]) {
		    case 0:
			if ((0x3ff000000000000L & l) != 0L) {
			    i_9_ = 1;
			    jjstateSet[jjnewStateCnt++] = 0;
			}
			/* fall through */
		    default:
			if (i_8_ == i_7_)
			    break while_4_;
		    }
		}
	    } else if (curChar < '\u0080') {
	    while_3_:
		for (;;) {
		    switch (jjstateSet[--i_8_]) {
		    default:
			if (i_8_ == i_7_)
			    break while_3_;
		    }
		}
	    } else {
		int i_10_ = curChar >> 8;
	    while_2_:
		for (;;) {
		    switch (jjstateSet[--i_8_]) {
		    default:
			if (i_8_ == i_7_)
			    break while_2_;
		    }
		}
	    }
	    if (i_9_ != 2147483647) {
		jjmatchedKind = i_9_;
		jjmatchedPos = i_6_;
		i_9_ = 2147483647;
	    }
	    i_6_++;
	    if ((i_8_ = jjnewStateCnt) == (i_7_ = 1 - (jjnewStateCnt = i_7_)))
		return i_6_;
	    try {
		curChar = input_stream.readChar();
	    } catch (java.io.IOException ioexception) {
		return i_6_;
	    }
	}
    }
    
    public OIDParserTokenManager(SimpleCharStream simplecharstream) {
	input_stream = simplecharstream;
    }
    
    public OIDParserTokenManager(SimpleCharStream simplecharstream, int i) {
	this(simplecharstream);
	SwitchTo(i);
    }
    
    public void ReInit(SimpleCharStream simplecharstream) {
	jjmatchedPos = jjnewStateCnt = 0;
	curLexState = defaultLexState;
	input_stream = simplecharstream;
	ReInitRounds();
    }
    
    private final void ReInitRounds() {
	jjround = -2147483647;
	int i = 1;
	while (i-- > 0)
	    jjrounds[i] = -2147483648;
    }
    
    public void ReInit(SimpleCharStream simplecharstream, int i) {
	ReInit(simplecharstream);
	SwitchTo(i);
    }
    
    public void SwitchTo(int i) {
	if (i >= 1 || i < 0)
	    throw new TokenMgrError(("Error: Ignoring invalid lexical state : "
				     + i + ". State unchanged."),
				    2);
	curLexState = i;
    }
    
    protected Token jjFillToken() {
	Token token = Token.newToken(jjmatchedKind);
	token.kind = jjmatchedKind;
	String string = jjstrLiteralImages[jjmatchedKind];
	token.image = string == null ? input_stream.GetImage() : string;
	token.beginLine = input_stream.getBeginLine();
	token.beginColumn = input_stream.getBeginColumn();
	token.endLine = input_stream.getEndLine();
	token.endColumn = input_stream.getEndColumn();
	return token;
    }
    
    public Token getNextToken() {
	boolean bool = false;
	try {
	    curChar = input_stream.BeginToken();
	} catch (java.io.IOException ioexception) {
	    jjmatchedKind = 0;
	    Token token = jjFillToken();
	    return token;
	}
	jjmatchedKind = 2147483647;
	jjmatchedPos = 0;
	int i = jjMoveStringLiteralDfa0_0();
	if (jjmatchedKind != 2147483647) {
	    if (jjmatchedPos + 1 < i)
		input_stream.backup(i - jjmatchedPos - 1);
	    Token token = jjFillToken();
	    return token;
	}
	int i_11_ = input_stream.getEndLine();
	int i_12_ = input_stream.getEndColumn();
	String string = null;
	boolean bool_13_ = false;
	try {
	    input_stream.readChar();
	    input_stream.backup(1);
	} catch (java.io.IOException ioexception) {
	    bool_13_ = true;
	    string = i <= 1 ? "" : input_stream.GetImage();
	    if (curChar == '\n' || curChar == '\r') {
		i_11_++;
		i_12_ = 0;
	    } else
		i_12_++;
	}
	if (!bool_13_) {
	    input_stream.backup(1);
	    string = i <= 1 ? "" : input_stream.GetImage();
	}
	throw new TokenMgrError(bool_13_, curLexState, i_11_, i_12_, string,
				curChar, 0);
    }
}